import { default as request, cloud } from '@/framework/utils/request'

// 查询接口服务监测列表
export function listServiceMonitor(query) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/page',
    method: 'get',
    params: query
  })
}

// 查询接口服务监测详细
export function getServiceMonitor(id) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/detail?id=' + id,
    method: 'get'
  })
}

// 新增接口服务监测
export function addServiceMonitor(data) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/add',
    method: 'post',
    data: data
  })
}

// 修改接口服务监测
export function updateServiceMonitor(data) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/edit',
    method: 'post',
    data: data
  })
}

// 删除接口服务监测
export function delServiceMonitor(id) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/delete',
    method: 'post',
    data: { ids: id }
  })
}

// 连接测试接口
export function connectTest(data) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/connectTest',
    method: 'post',
    data
  })
}

// 下载模板
export function downloadTemplateApiInter() {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/downloadTemplate',
    method: 'post',
    params: {
      'enclosure': '接口服务状态监控导入模板.xlsx'
    },
    responseType: 'arraybuffer'
  })
}

// 全部导出
export function exportAllInter(data) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/exportAll',
    method: 'post',
    data,
    responseType: 'arraybuffer'
  })
}

// 部分导出
export function partExportInter(params) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/export',
    method: 'post',
    params,
    responseType: 'arraybuffer'
  })
}

// 导入
export function uploadApiInter(data) {
  return request({
    url: cloud.interfacePlatform + '/interfaceServiceMonitor/upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
